﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class CheckYCList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userName"] == null || Session["roleID"] == null)
        {
            Response.Redirect("Login.aspx");
            Response.End();
        }
        if (!Page.IsPostBack)
        {
            if (Request.UrlReferrer != null)
            {
                lblBackUrl.Text = Request.UrlReferrer.ToString();
            }
            BindToDdlYear();
            BindCheckYC();
        }
    }
    //绑定未处理异常信息
    protected void BindCheckYC()
    {
        string userName = Session["userName"].ToString();
        string roleID = Session["roleID"].ToString();
        string userCondition = "";        
            userCondition = " and CURRENTOPERATER='" + userName + "'";
        
        string dataYear=ddlYear.SelectedValue.ToString();
        string YCMsgTabName = "YCMS" + dataYear;
        string sqlString = "select * from " + YCMsgTabName + " where STATUS='0'" + userCondition + " order by ADDDATE DESC,AUTOID DESC";        
        DBOperation DBO = new DBOperation();
        DataSet ds = DBO.GetDataSet(sqlString, "CheckYC");
        RpYCList.DataSource = ds.Tables["CheckYC"].DefaultView;
        RpYCList.DataBind();        
        
    }

    //绑定数据到选择年份下拉列表
    private void BindToDdlYear()
    {
        BasicClass BC = new BasicClass();
        int currentYear = Convert.ToInt32(DateTime.Now.Year.ToString());
        Hashtable htYear = BC.GetDataYear();
        ddlYear.DataSource = htYear;
        ddlYear.DataTextField = "value";
        ddlYear.DataValueField = "key";
        ddlYear.DataBind();
        ddlYear.SelectedValue = currentYear.ToString();
    }
    protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindCheckYC();
    }    
    protected void btnBack_Click(object sender, EventArgs e)
    {
        string refURL = "MessageInfo.aspx";

        refURL = lblBackUrl.Text;
        string toFileName = refURL.Substring(refURL.LastIndexOf("/")+1);
        if (refURL == "" || refURL == null || toFileName == "MenuDir.aspx")
        {
            refURL = "MessageInfo.aspx";
            

        }
        Response.Redirect("MessageInfo.aspx");

    }
}
